Skip to content

fix: use python3 JSON parser in checkLatestRelease() instead of grep#8808

Open
vijaygovindaraja wants to merge 2 commits intomakeplane:previewfrom
vijaygovindaraja:fix/8775-json-parsing-checkLatestRelease
Open

fix: use python3 JSON parser in checkLatestRelease() instead of grep#8808
vijaygovindaraja wants to merge 2 commits intomakeplane:previewfrom
vijaygovindaraja:fix/8775-json-parsing-checkLatestRelease

Conversation

@vijaygovindaraja
Copy link
Copy Markdown

@vijaygovindaraja vijaygovindaraja commented Mar 27, 2026

Closes #8775

Summary

checkLatestRelease() uses a grep pattern that assumes spaces after colons in GitHub API JSON responses. When GitHub
returns compact/minified JSON, the pattern fails and the install script aborts.

Fix

Replace grep + sed with python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" which handles both
compact and formatted JSON. python3 is already a prerequisite for the Docker setup.

Applied to both:

  • deployments/cli/community/install.sh
  • deployments/swarm/community/swarm.sh

Verification

# Old pattern fails on compact JSON
echo '{"tag_name":"v1.2.3"}' | grep -o '"tag_name": "[^"]*"'  # no match

# New pattern works on both formats
echo '{"tag_name":"v1.2.3"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])"  # v1.2.3
echo '{"tag_name": "v1.2.3"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])"  # v1.2.3

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Refactor**
* Improved release-version detection by switching to robust JSON parsing.
* **Bug Fixes**
* Installer scripts now require Python 3 and will exit with a clear error if absent.
* **Stability**
* Output handling tightened (proper quoting) to prevent unexpected parsing or formatting issues.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 27, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2afb3d02-6a0a-4c6f-804e-190f5777926e

📥 Commits

Reviewing files that changed from the base of the PR and between 1b4d095 and be51184.

📒 Files selected for processing (2)
  • deployments/cli/community/install.sh
  • deployments/swarm/community/swarm.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • deployments/swarm/community/swarm.sh

📝 Walkthrough

Walkthrough

Replaced brittle grep/sed JSON parsing with a python3-based parse of GitHub releases and added an explicit python3 presence check; final release tag is echoed quoted. Changes apply to two deployment scripts.

Changes

Cohort / File(s) Summary
GitHub release parsing
deployments/cli/community/install.sh, deployments/swarm/community/swarm.sh
Replaced grep/sed extraction of "tag_name" with python3 -c 'import sys,json; print(json.load(sys.stdin)[\"tag_name\"])', added a command -v python3 check that exits if missing, and switched to echo "$latest_release" for output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I munched through JSON, sharp and neat,

No fragile grep left in my seat,
Python peeks where tags reside,
Compact or spaced — I hop with pride. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: replacing grep with a Python 3 JSON parser in checkLatestRelease().
Description check ✅ Passed The description adequately explains the problem, solution, and affected files; includes verification examples and closes the related issue.
Linked Issues check ✅ Passed All coding requirements from issue #8775 are met: the grep pattern is replaced with Python 3 JSON parsing in both affected files to handle compact and formatted JSON.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the JSON parsing issue in checkLatestRelease() across the two specified files; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@deployments/cli/community/install.sh`:
- Line 60: The script currently assumes python3 exists and assigns in one step
which masks command failures; modify the install flow by first checking for
python3 (e.g., test -x "$(command -v python3)" and emit a clear error if
missing) and then split the declaration and assignment for latest_release:
declare local latest_release on its own then assign the output of the
curl|python3 pipeline to it (so failures are visible and SC2155 is avoided).
Apply the identical change to the other occurrence referenced in
deployments/swarm/community/swarm.sh at the line that sets latest_release.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ce46a28b-a5ed-4e81-9321-878153f351e7

📥 Commits

Reviewing files that changed from the base of the PR and between 130ba5e and 8be000c.

📒 Files selected for processing (2)
  • deployments/cli/community/install.sh
  • deployments/swarm/community/swarm.sh

The grep pattern `"tag_name": "[^"]*"` assumes a space after the colon
in the GitHub API JSON response. When GitHub returns compact/minified
JSON without spaces, the pattern fails and the install script aborts
with "Failed to check for the latest release."

Replace grep+sed with python3's json module which handles both compact
and formatted JSON reliably. python3 is already a prerequisite for the
Docker setup scripts.

Applied to both install.sh (CLI) and swarm.sh (Docker Swarm).

Closes makeplane#8775
- Add explicit `command -v python3` check with clear error message
- Separate `local` declaration from assignment (SC2155)
- Use `-fsSL` curl flags and quote the URL
- Quote `$latest_release` in echo

Addresses review feedback from CodeRabbit.
@vijaygovindaraja vijaygovindaraja force-pushed the fix/8775-json-parsing-checkLatestRelease branch from 1b4d095 to be51184 Compare March 28, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: checkLatestRelease() fails when GitHub API returns compact JSON

2 participants